package red.mlz.module.module.game.service;

import red.mlz.module.module.game.es.GameEs;
import red.mlz.module.module.game.es.GameEsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class GameSearchService {

    @Autowired
    private GameEsRepository gameEsRepository;

    /**
     * 搜索游戏
     */
    public Page<GameEs> searchGames(String keyword, Pageable pageable) {
        if (keyword == null || keyword.trim().isEmpty()) {
            return gameEsRepository.findAll(pageable);
        } else {
            return gameEsRepository.searchByKeyword(keyword, pageable);
        }
    }
}